package com.qire.other.advert;

import com.qire.other.advert.impl.PangolinAdvert;

import androidx.fragment.app.FragmentActivity;

/**
 * 广告工厂更具不同广告商或者广告代码生产一个广告对象。
 */
public class AdvertFactory {

    /**
     * 通过广告商来构造一个广告对象
     * @param advertiser 广告商
     * @param advertCode 广告联盟生成的具体广告代码
     * @return 广告商的一个广告对象。
     * @see Advertiser
     */
    public static Advert create(Advertiser advertiser, String advertCode) {
        switch (advertiser){
            case PANGOLIN:
                return new PangolinAdvert(advertCode);
            case TENCENT:
            case BAIDU:
            case GOOGLE:
            case UNKNOWN:
            default:
                return new UnAdvertise(advertCode);
        }
    }

    /**
     * 提供的默认未定义广告对象，如果广告对象为实现则返回该对象。
     */
    private static class UnAdvertise extends Advert {
        public UnAdvertise(String advertCode) {
            super(advertCode);
        }

        @Override
        public void playVideo(FragmentActivity activity) { }

        @Override
        public void injectionBanner(AdvertDockingDevice advertDockingDevice, int layoutRid) { }

        @Override
        public void injectionInfoFlow(AdvertDockingDevice advertDockingDevice) { }

        @Override
        public void injectionSplash(AdvertDockingDevice advertDockingDevice, boolean disableCountdown, int timeOut) { }
    }
}
